package com.dospyer.consumer.controller;

import com.dospyer.provider.api.ProviderApi;
import com.dospyer.provider.api.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("/feign")
public class FeignController {

    @Resource
    private ProviderApi providerApi;

    @GetMapping(value = "/sayHello/{id}")
    public String greeting(@PathVariable("id") Long id, @RequestParam("name") String name, @RequestParam("age") Integer age) {
        log.info("feign controller sayHello, id={}, name={}, age={}", id, name, age);
        return providerApi.sayHello(id, name, age);
    }

    @GetMapping(value = "/")
    public String createUser(User user) {
        log.info("feign controller createUser，user={}", user);
        return providerApi.createUser(user);
    }
}
